<template>
  <div class="detail">
    <iframe :src="url" frameborder="0" style="min-height:600px;width:100%;height:100%;" scrolling="no"></iframe>
  </div>
</template>
<script>
  export default {
    name: 'ProductDetailPhone',
    data () {
      return {
        productName: '',
        imageUrl: '',
        price: '',
        serialNum: '',
        machineID: '',
        code: '',
        state: '',
        url: '',
        appid: 'wxcfd3b759765ff7ee',
        redirectUri: '',
      }
    },

    created() {

      let str = decodeURIComponent(location.href);
//      console.log(str);
      let arr = str.split('?')[1].split('&');
//      console.log(arr);
      this.serialNum = arr[0].split('=')[1];
      this.imageUrl = arr[1].split('=')[1];
      this.price = arr[2].split('=')[1];
      this.productName = arr[3].split('=')[1];
      this.machineUid = arr[4].split('=')[1];
      this.wx_redirectUri = `http://product.bandtechs.cn?serialNum=${this.serialNum}&imageUrl=${this.imageUrl}&price=${this.price}&name=${this.productName}&machineUid=${this.machineUid}`;
      this.zfb_redirectUri = `http://product.bandtechs.cn/#/zfb?serialNum=${this.serialNum}&imageUrl=${this.imageUrl}&price=${this.price}&name=${this.productName}&machineUid=${this.machineUid}`;

      if(navigator.userAgent.toLowerCase().includes('micromessenger')){
        location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.appid}&redirect_uri=${encodeURIComponent(this.wx_redirectUri)}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`;
      }else if(navigator.userAgent.toLowerCase().includes('alipayclient')){
        location.href = this.zfb_redirectUri;
      }
    },
//    methods: {
//      payType () {
//        let api = 'http://manage.bandtechs.com/public/pay/selectPayType?';
//        this.$http.get(api).then((res) =>{
//          let resData = res.data;
//          if(resData.code == 200){
//            switch (resData.type){
//              case 1:
//                break;
//              case 2:
//
//                break;
//              default:
//                break;
//            }
//          }
//        });
//      }
//    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>


</style>
